package com.peter.viewperformanceclick;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e(TAG, "onClick: the fucking button");

                findViewById(R.id.textView).performClick();
            }
        });

        findViewById(R.id.textView).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e(TAG, "onClick: tv fucking touched");
            }
        });

        findViewById(R.id.textView).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {

                TextView tv = (TextView) view;
                tv.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaaa");

                Log.e(TAG, "onTouch: X Y" + motionEvent.getX() + "  " + motionEvent.getY(),null );

                Log.e(TAG, "onTouch: RAW  X Y" + motionEvent.getRawX() + "  " + motionEvent.getRawY(),null );

                Toast.makeText(MainActivity.this, "Touch Touch", Toast.LENGTH_SHORT).show();

                return false;
            }
        });


    }
}